package com.linliusheng.service;

import javax.swing.*;
import java.awt.*;

/**
 * @author linyanbin
 * @date 2022/5/7 20:54
 */
public class Login extends JFrame {


    static JLabel titleLabel;
    static JLabel accountLabel;
    static JLabel passWordLabel;

    static JTextField accountText;
    static JPasswordField passWordText;

    static JPanel panel;

    static JButton loginButton;
    static Font titleFont;
    static Font font;

    static Image imageIcon;

    public Login(){
        super("登录");
        setLayout(null);
        setSize( 600, 500);
        // 设置窗口相对于屏幕居中
        setLocationRelativeTo(null);
        iconSet();
        panelSet();
        fontSet();
        labelSet();
        textSet();
        buttonSet();
        getContentPane().setBackground(new Color(65, 113, 218));

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }
    public void iconSet() {
        imageIcon = new ImageIcon("myIcon.jpg").getImage();
        setIconImage(imageIcon);
    }
    public void panelSet() {
        panel = new JPanel();
        panel.setLayout(null);
        panel.setBounds(120, 100, 350, 300);
        add(panel);
    }
    public void labelSet() {
        titleLabel = new JLabel("欢迎来到图书管理系统");
        accountLabel = new JLabel("账号");
        passWordLabel = new JLabel("密码");

        titleLabel.setFont(titleFont);
        accountLabel.setFont(font);
        passWordLabel.setFont(font);

        titleLabel.setBounds(110, 30, 400, 40);
        accountLabel.setBounds(60, 40, 70, 30);
        passWordLabel.setBounds(60, 140, 70, 30);
        panel.add(accountLabel);
        panel.add(passWordLabel);
        add(titleLabel);
    }
    public void textSet() {
        accountText = new JTextField();
        passWordText = new JPasswordField();

        passWordText.setEchoChar('●');

        accountText.setFont(font);
        passWordText.setFont(font);

        accountText.setBounds(60, 75, 220, 40);
        passWordText.setBounds(60, 175, 220, 40);

        panel.add(accountText);
        panel.add(passWordText);
    }
    public void buttonSet() {
        loginButton = new JButton("登录");
        loginButton.setFont(font);
        loginButton.setBounds(130, 230, 100, 50);
        panel.add(loginButton);
    }
    public void fontSet() {
        titleFont = new Font("黑体", Font.BOLD, 36);
        font = new Font("黑体", Font.BOLD, 23);
    }


    public static void main(String[] args) {
        new Login();
    }
}
